#include<bits/stdc++.h>
using namespace std;
#define int long long

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};

int n, m;
char mp[505][505];
bool vis[505][505];

struct node {
	int x, y;
};

int ans;

void bfs(int x, int y) {
	queue<node> q;
	q.push({x, y});
	vis[x][y] = 1;

	while (!q.empty()) {
		node t = q.front();
		q.pop();

		ans--;

		for (int i = 0; i < 4; i++) {
			int xx = t.x + dx[i];
			int yy = t.y + dy[i];

			if (xx < 1 || xx > n || yy < 1 || yy > m || vis[xx][yy])
				continue;

			q.push({xx, yy});
			vis[xx][yy] = 1;
		}
	}
}

signed main() {
	cin >> n >> m;

	ans = n * m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> mp[i][j];
			if (mp[i][j] == '*') {
				vis[i][j] = 1;
				ans--;
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		if (!vis[i][1])	bfs(i, 1);
		if (!vis[i][m])	bfs(i, m);
	}
	for (int i = 1; i <= m; i++) {
		if (!vis[1][i])	bfs(1, i);
		if (!vis[n][i])	bfs(n, i);
	}


	cout << ans;
	return 0;
}
